/**
* Created by yyr
* 编辑管理机构信息
*/
<template>
    <div class="ca-p-20">
        <div class="ca-title">
            <h3>管理机构信息</h3>
            <div class="ca-align-right" v-if="!isAdd">
                <el-button type="primary" size="medium" @click="saveManageOrg">保存</el-button>
                <el-button size="medium" @click="cancel()">取消</el-button>
            </div>
        </div>
        <el-form  label-width="150px" :model="fundMechanism" class="ca-m-t-20" ref="mechanismForm" :rules="rules">
            <el-row :gutter="10">
                <el-col :span='11'>
                    <el-form-item label="机构名称" label-width="160px">
                        <el-input style="width:100%" v-model="fundMechanism.mechanismName" :maxlength="100"></el-input>
                    </el-form-item>
                    <el-form-item label="执行事务合伙人" label-width="160px">
                        <el-input style="width:100%" v-model="fundMechanism.partner" :maxlength="100"></el-input>
                    </el-form-item>
                    <el-form-item label="成立时间" label-width="160px">
                        <el-date-picker
                        type="date"
                        placeholder="选择日期"
                        style="width:100%"
                        v-model="fundMechanism.foundingTime">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="认缴金额(万元)" label-width="160px" prop="subscribed">
                        <el-input style="width:100%" v-model="fundMechanism.subscribed"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span='11'>
                    <el-form-item label="法人代表" label-width="160px">
                        <el-input style="width:100%" v-model="fundMechanism.representative" :maxlength="100"></el-input>
                    </el-form-item>
                    <el-form-item label="注册资本(万元)" label-width="160px" prop="register">
                        <el-input style="width:100%" v-model="fundMechanism.register"></el-input>
                    </el-form-item>
                    <el-form-item label="实缴金额(万元)" label-width="160px" prop="receipts">
                        <el-input style="width:100%" v-model="fundMechanism.receipts"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
           <el-row>
               <el-col :span="23">
                   <csRegion title="注册地点"
                             :address="address"
                             :labelWidth=labelWidth
                             ref="regist">
                   </csRegion>
               </el-col>
           </el-row>
            <el-row :gutter="10">
                <el-col :span="22">
                    <el-form-item label="股东出资金额和比例" label-width="160px">
                        <el-input type="textarea" style="width:100%" :maxlength="4000" v-model="fundMechanism.proportion"></el-input>
                    </el-form-item>
                    <el-form-item label="公司治理" label-width="160px">
                        <el-input type="textarea" style="width:100%" :maxlength="4000" v-model="fundMechanism.govern"></el-input>
                    </el-form-item>
                    <el-form-item label="内控机制" label-width="160px">
                        <el-input type="textarea" style="width:100%" :maxlength="4000" v-model="fundMechanism.mechanism"></el-input>
                    </el-form-item>
                    <el-form-item label="管理制度" label-width="160px">
                        <el-input type="textarea" :maxlength="4000" style="width:100%" v-model="fundMechanism.rule"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
    </div>
</template>
<script type="text/ecmascript-6">
    export default {
        data() {
            return {
                labelWidth: '160px',
                address: {
                    province: '',
                    city: '',
                    district: '',
                    businessType: 1,
                    registrationDetailed: ''
                },
//                fundMechanism: {
//                    foundingTime: '', //成立时间
//                    fundId: '', //基金id
//                    govern: '', //公司治理
//                    id: '', //主id
//                    mechanism: '', //内控机制
//                    mechanismName: '', //机构名称
//                    partner: '', //执行事务合伙人
//                    proportion: 0, //股东出资金额和比例
//                    receipts: 0, //实收资本
//                    region: [ //注册地址
//                    {
//                        businessId: '',
//                        businessType: 0,
//                        city: '',
//                        district: '',
//                        id: '',
//                        province: '',
//                        registrationDetailed: ''
//                    }
//                    ],
//                    register: 0, //注册资本
//                    representative: '', //法定代表人
//                    rule: '', //管理制度
//                    subscribed: 0 //认缴金额
//                },
                rules: {
                    //认缴金额
                    subscribed: [
                        { validator: this.validateMoneyNumber, trigger: 'blur' }
                    ],
                    register: [
                        { validator: this.validateMoneyNumber, trigger: 'blur' }
                    ],
                    receipts: [
                        { validator: this.validateMoneyNumber, trigger: 'blur' }
                    ]
                }
            }
        },
        props: {
            isAdd: {
                type: Boolean,
                default() {
                    return false;
                }
            },
            fundMechanism: {
                type: Object,
                default() {
                    return {};
                }
            }
        },
        created() {
        },
        watch: {
            // 深度 watcher
            fundMechanism: {
                handler: function (fundMechanism) {
                    this.$refs.mechanismForm.validate((valid) => {
                        if (valid) {
                            this.$emit('fundMechanism', fundMechanism);
                        } else {
                            return false;
                        }
                    });
                },
                deep: true
            },
            address: {
                handler(val) {
                    this.$emit('changeRegion', val)
                },
                deep: true
            }
        },
        mounted() {
            if (this.fundMechanism.region && this.fundMechanism.region.length > 0) {
                this.address = {
                    province: this.fundMechanism.region[0].province,
                    city: this.fundMechanism.region[0].city,
                    district: this.fundMechanism.region[0].district,
                    businessType: 1,
                    registrationDetailed: this.fundMechanism.region[0].registrationDetailed
                };
                this.$refs.regist.inview(this.address)
            }
        },
        methods: {
            cancel() {
                this.$emit('close')
            },
            //修改管理机构
            saveManageOrg() {
                this.$refs.mechanismForm.validate((valid) => {
                    if (valid) {
                        this.$emit('saveManageOrg',this.fundMechanism)
                    } else {
                        return false;
                    }
                });
            },
        },
        components: {
            'csRegion': require('__components/region/index'), // 注册地点组件
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>

</style>
